[rtl] Switch to ratified bitmanip extensions#2459
Conversation
d0b04a1 to
359815f
Compare
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
359815f to
242bc59
Compare
Signed-off-by: Thomas Benz <tbenz@lowrisc.org>
afac420 to
6062faa
Compare
marnovandermaas
left a comment
There was a problem hiding this comment.
Initial comments from me. Do you think it is worth squashing the commits that just remove things? I think it may be excessive to have 9 separate commits for removing instructions.
| {7'b000_0100, 3'b100}, // pack | ||
| {7'b000_0100, 3'b111}, // packh |
There was a problem hiding this comment.
The zexth commit also remove pack and packh
| 5'b0_0000: alu_operator_o = ALU_SRL; // Shift Right Logical by Immediate | ||
| 5'b0_1000: alu_operator_o = ALU_SRA; // Shift Right Arithmetically by Immediate | ||
| 5'b0_1001: alu_operator_o = ALU_BEXT; // Extract bit specified by immediate. | ||
| // rori (Zbb, also imported by Zbkb): rotate right by immediate |
There was a problem hiding this comment.
Why does changing this comment complete Zbkb?
| * `RISC-V Bit-Manipulation Extension, version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ and `version 0.93 (draft from January 10, 2021) <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.93.pdf>`_ | ||
| * `RISC-V Bit-Manipulation Extension, version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ | ||
| * `RISC-V Scalar Cryptography Extension, version 1.0.1 <https://github.com/riscv/riscv-crypto/releases/download/v1.0.1-scalar/riscv-crypto-spec-scalar-v1.0.1.pdf>`_ (Zbkb, Zbkx sub-extensions only) |
There was a problem hiding this comment.
The commit for this shouldn't be marked as RTL. Probably [doc,dv] would be better.
I have them as individual commits to help people review the changes. I would have squashed all into one after the review process. What do you think? |
SamuelRiedel
left a comment
There was a problem hiding this comment.
Thanks for cleaning up the bitmanip @thommythomaso. I did a quite thorough review, but most of it should be easy to fix.
The only thing that is left is that we should update RISC-V DV to also support the latest ratified extensions. I saw that the ratified B extensions are supported already, but for the scalar crypto ones, we currently simply enable the Zbp still, right? I think this is good enough for now, but we should create an issue documenting the current state, like which instructions are emitted by riscv-dv and which aren't and what we would ideally want to then clean up the DV in a second step at least.
| Ibex implements the Machine ISA version 1.12. | ||
| * `RISC-V External Debug Support, version 0.13.2 <https://content.riscv.org/wp-content/uploads/2019/03/riscv-debug-release.pdf>`_ | ||
| * `RISC-V Bit-Manipulation Extension, version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ and `version 0.93 (draft from January 10, 2021) <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.93.pdf>`_ | ||
| * `RISC-V Bit-Manipulation Extension, version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ |
There was a problem hiding this comment.
Should we explicitly mention the subextensions? The "B" only stands for Zba, Zbb, and Zbs in the ISA string, but then the Zbc is also part of the bit manipulation extension. This is a bit confusing in the RISC-V spec already, but I would explicitly mention what we support already in this file here and in the list below.
|
|
||
| * - **B**: Standard Extension for Bit-Manipulation Instructions | ||
| - 1.0.0 + 0.93 [#B_draft]_ | ||
| - 1.0.0 [#B_draft]_ |
There was a problem hiding this comment.
This footnote doesn't really make sense anymore. We have the same footnote, named B_draft internally that describes what the fully ratified B extension entails and then also refer to the same footnote for the scalar crypto one. Let's have one footnote each or just leave them away, since the scalar crypto is already clear on its own and if we clarify the bitmanip above already, I also don't think we need a footnote specifying the subextensions anymore.
|
|
||
| Bit-Manipulation Extension | ||
| Support for the `RISC-V Bit-Manipulation Extension version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ and `draft version 0.93 from January 10, 2021 <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.93.pdf>`_ is optional. [#B_draft]_ | ||
| Support for the `RISC-V Bit-Manipulation Extension version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_, together with the Zbkb and Zbkx sub-extensions of the ratified Scalar Cryptography Extension, is optional. [#B_draft]_ |
There was a problem hiding this comment.
Again, outdated footnote name
| The implementation of the Bit-Manipulation Extension comes with an area overhead of 2.7 kGE for the balanced version, 6.1 kGE for the OTEarlGrey version, and 7.5 kGE for the full version. | ||
| These numbers were obtained by synthesizing the design with Yosys and relaxed timing constraints. |
There was a problem hiding this comment.
Do we have any new numbers for those? Even if we could simply estimate them?
| uint32_t misa_val = processor->get_csr(CSR_MISA); | ||
| if (rv32b_enabled) { | ||
| misa_val |= 1 << 1; | ||
| } | ||
| processor->get_state()->csrmap[CSR_MISA] = | ||
| std::make_shared<const_csr_t>(processor.get(), CSR_MISA, misa_val); | ||
|
|
There was a problem hiding this comment.
Why is the B extension a special case here where we need to parse the ISA string ourselves and inject it into the MISA register? Shouldn't this be handled the same way as all the other extensions?
| end | ||
| 5'b0_1001, // bclri | ||
| 5'b0_0101, // bseti | ||
| 5'b0_1101: illegal_insn = (RV32B != RV32BNone) ? 1'b0 : 1'b1; // binvi |
There was a problem hiding this comment.
These instructions require instr[25] to be zero as well in RV32, which is never checked, right?
| if ({instr[26], instr[13:12]} == {1'b1, 2'b01}) begin | ||
| illegal_insn = (RV32B != RV32BNone) ? 1'b0 : 1'b1; // cmix / cmov / fsl / fsr | ||
| illegal_insn = 1'b1; // cmix / cmov / fsl / fsr removed |
There was a problem hiding this comment.
Do we still need this? They will simply fall under the default case later, right? I think the comment will be a bit confusing if someone looks at this without the context of the bitmanip just being cleaned up.
| default: ; | ||
| endcase | ||
| end | ||
| // Ternary bitmanip ops (cmix/cmov/fsl/fsr) removed; these encodings are illegal. |
There was a problem hiding this comment.
Here we again have an empty if block and the else only contains a switch case with legal encodings, so we could directly use the switch case only, no?
| @@ -124,174 +116,30 @@ package ibex_tracer_pkg; | |||
| parameter logic [31:0] INSN_BEXT = { 7'b0100100, 10'h?, 3'b101, 5'h?, {OPCODE_OP} }; | |||
|
|
|||
| // ZBP | |||
There was a problem hiding this comment.
Mention of old extension
| // The generalized-reverse / or-combine butterfly below implements the ratified | ||
| // subset only: rev8 and orc.b. | ||
|
|
||
| logic [4:0] zbp_shift_amt; |
There was a problem hiding this comment.
Mention of old extension in variable name
No description provided.